local courseId = ARGV[1]
local userId = ARGV[2]
-- string
local stockKey = "course:stock:" .. courseId
-- set
local grabbedKey = "course:isGrabbed"

-- 判断用户是否抢过课
local member = userId
if (redis.call('sismember', grabbedKey, member) == 0) then
    return 1
end

-- 增库存
redis.call('incrby', stockKey, '1')
-- 删除用户抢课信息
redis.call('srem', grabbedKey, member)
return 0